
typedef enum _Job_type {
  MKDIR,
  PUT,
  GET
} Job_type;

struct Inode {
  int num_pending_updates;
  int is_dir; //bool
  int id; //local identifier
  int ip[2];
  char *filename;
  char *content;
};

typedef enum _Dir_response_type {
  FOUND,
  LASTDIR,
  PUTREADY,
  OVERWRITE,
  ERROR
} Dir_response_type;

struct Dir_response {
  Dir_response_type type;
  char *data;
};


conditional variables for thread wakeup;
worker file pointer;
resolver queue;
auth_action;
auth_client_address;
auth_line_number;

main() {
  create threads;
  signal dispatcher thread;
  join dispatcher thread;
  pause for user;
  return 0;
}


dispatcher thread()
{
  make local file pointer to input file;
  open file;
  while (! eof) {
    nanosleep(random, empty);
    read a line;
    add line to resolver queue;
    signal resolver;
  }
  thread exit;
}


resolver() {
  while (1) {
    wait on resolver conditional variable();
    get head from queue;
    process line() {
      client_add = ...
      request type = ...
      file path = ...

      if f(request type, file path) != error {
        load auth values;
        signal auth;
        wait on resolver
        if (!athenticated) issue error;
        else {
          load up inode;
          add inode to queue;
          broadcast workers;
        }
      }
      else {
        //dependency checks and hhhhwhatnot.
      }
    }
  }
}


authentication() {
  while (1) {
    wait on auth_condition
    local auth_variables = auth_...;
    check access() {
      ip[2] = dirmodule.getperm(line number);
      if 0 matches access = no access
      if first only matches access = read;
      if both match access = read/write;
  
      if GET && access != 0 auth_result = 1;
      if PUT && access == read/write auth_result = 1;
      else
        auth_result = 0;
    }
    signal resolver;
  }
}


worker() {
  while (1) {
    wait on worker_condition;
    while (queue not empty) {
      get head from queue;
      if GET print info;
      // directory functions atomic
      else if PUT call dirmodule.put()
      else if MKDIR call dirmodule.mkdir()
    }
  }
}


